 
#include "PwrMgnt.h"

#if defined (pwrmgnt_v1_1) || defined (pwrmgnt_v2_1) || defined (LIB_BUILD)
/******************************************************************************
 * Function:        RESET_SOURCE PwrMgnt_ResetSource(void)
 *
 * PreCondition:    None   
 *
 * Side Effects:    None
 *
 * Overview:        This function returns the source of reset.
 *
 * Input:           None
 *
 * Returns:          RESET_SOURCE - Enum value representing the source of reset
 *
 * Note:            None
 *****************************************************************************/
RESET_SOURCE PwrMgnt_ResetSource(void)
{
   if(RCONbits.POR)
   {
      return(POWER_ON_Reset);
   }
   if((RCONbits.BOR) && !(RCONbits.POR))
   {
      return(BURN_OUT_Reset);
   }
   if(RCONbits.WDTO)
   {
      return(WATCHDOG_Reset);
   }
   if(RCONbits.SWR)
   {
      return(SOFTWARE_Reset);
   }
   if(RCONbits.EXTR)
   {
      return(EXTERNAL_Reset);
   }
   if(RCONbits.CM)
   {
      return(CFG_WORD_MISMATCH_Reset);
   }
   if(RCONbits.IOPUWR)
   {
      return(ILLEGAL_INSTR_Reset);
   }
   if(RCONbits.TRAPR)
   {
      return(TRAP_Reset);
   }
}

#else
#warning "Selected device not supports this function"
#endif
